﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeWork.Library.DataStructure;

namespace BDHomePage.BLL
{
    public class LinkCategory
    {
        private int _id;
        public int Id
        {
            get { return this._id; }
        }

        private ReadWriteCustomCollection<Link> _links;
        public ReadOnlyCustomCollection<Link> Links
        {
            get { return this._links.ReadOnlyClone(); }
        }

        private string _categoryName;
        public string CategoryName
        {
            get { return this._categoryName; }
            set { this._categoryName = value; }
        }

        private string _categoryDescription;
        public string CategoryDescription
        {
            get { return this._categoryDescription; }
            set { this._categoryDescription = value; }
        }

        private int _totalLinks;
        public int TotalLinks
        {
            get { return this._totalLinks; }
        }

        private DateTime _createDate;
        private DateTime CreateDate
        {
            get { return this._createDate; }
        }

        public LinkCategory()
        {
            this._id = 0;
            this._categoryDescription = string.Empty;
            this._categoryName = string.Empty;
            this._createDate = DateTime.Now;
            this._totalLinks = 0;
            this._links = new ReadWriteCustomCollection<Link>();
        }

        public void AddLinkCategory()
        {
            // Check whether there is already a category with
            // same name
            int categoryWithSameNameCount = 0;
        }

        public void RemoveLinkCategory()
        {
            //DB Code to remove an existing link
        }

        public void UpdateLinkCategory()
        {
            // DB code to update linkscategory
        }

        public void RemoveLinkFromCategory(Link linkToRemove)
        {
            this._totalLinks--;
            this._links.Remove(linkToRemove);
            // Code to update Database
        }

        public void AddLinkToCategory(Link linkToAdd)
        {
            this._totalLinks++;
            this._links.Add(linkToAdd);
        }
    }
}
